package graphicInterface;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.util.ArrayList;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.text.html.HTMLDocument.Iterator;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;

import database.IngredientManager;
import category.*;



public class GUI_AddIngredient extends JFrame {

	private JPanel contentPane;
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					GUI_AddIngredient frame = new GUI_AddIngredient();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public GUI_AddIngredient(CategoryCollection allC) {
		setTitle("Add Ingredient");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 111);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JLabel lblPleaseEnterThe = new JLabel("Please enter the name");
		contentPane.add(lblPleaseEnterThe, BorderLayout.NORTH);
		
		textField = new JTextField();
		contentPane.add(textField, BorderLayout.WEST);
		textField.setColumns(10);
		
		java.util.Iterator<Category> i  = allC.getCategoryList().values().iterator() ;
		ArrayList<String> ingredientsArray = new ArrayList<String> ();
		while(i.hasNext())
			
			ingredientsArray.add(i.next().getName()) ;
		//IngredientManager.loadIngredients();
		
		
		
		String[] array = ingredientsArray.toArray(new String[ingredientsArray.size()]);
		
		
		JComboBox comboBox = new JComboBox(array);
		
		
		contentPane.add(comboBox, BorderLayout.CENTER);
		
		String[] measurmentArray = {"kg","litre","piece"};
		JComboBox comboBox_1 = new JComboBox(measurmentArray);
		contentPane.add(comboBox_1, BorderLayout.EAST);
		
		JButton btnAdd = new JButton("Add");
		contentPane.add(btnAdd, BorderLayout.SOUTH);
	}

}
